<template>
	<div class="game-succ-content">
    <header-top :option="headerOption"></header-top>
		<div class="upper">
	    <img src="https://dl.app.gtja.com/nrng/shareimages/niu.png"/>
		</div>
		<div id="game-succ-down">
			<table class="down" >
			    <tr class="down-tr1">
			        <td class="down-tr1-td1" id="down-tr1-td1" @click='share2QQ()'>
			            <div><img src="~assets/images/qq.png"></div><br>
			            <div>QQ</div>
			        </td>
			        <td class="down-tr1-td2" id="down-tr1-td2" @click='share2WB()'>
			            <div><img src="~assets/images/weixin.png"></div><br>
			            <div>微信</div>
			        </td>
			    </tr>
			    <tr>
			        <td class="down-tr2-td1" id="down-tr2-td1" @click='share2WeChat()'>
			            <div><img src="~assets/images/weibo.png"></div><br>
			            <div>微博</div>
			        </td>
			        <td class="down-tr2-td2" id="down-tr2-td2" @click='share2WCTimeline()'>
			            <div><img src="~assets/images/pengyouquan.png"></div><br>
			            <div>朋友圈</div>
			        </td>
			    </tr>
			</table>
		</div>
	</div>
</template>

<script type="text/javascript">
import HeaderTop from 'components/HeaderTop'
import Constant from 'common/constant'
import RemoteDAO from 'common/remoteDAO'
import LocalDAO from 'common/localDAO'

	export default {
		name: 'BGSucc',
		components: {
			'header-top': HeaderTop
		},
		data(){
			return {
				headerOption: {
          title: '成功创建比赛',
          leftBtn: Constant.leftBtn.CLOSE,
          operations: []
        },
				userCode: LocalDAO.getUserCode(),
				gameSuccUrl: decodeURI(window.location.href)
			}
		},
		created: function () {
			// body...
			this.initEvent();
		},
		methods: {
			initEvent(){
				if(!this.userCode){
					this.$store.dispatch('setTip',{text:"哎呀出现bug了，没有获取到呢称或客户代码"});
				}

				var gameId = this.$route.query.gameId;
				var gameKind=this.$route.query.gameKind;
        var createrNickName=this.$route.query.createrNickName;
        var gameAmount=this.$route.query.gameAmount;
        var beginDate=this.$route.query.beginDate;
        var endDate=this.$route.query.endDate;
        var gameNeedAmount=this.$route.query.gameNeedAmount;
        var gameName=this.$route.query.gameName;
        var gamePWD=this.$route.query.gamePWD;
        var createrHead=this.$route.query.createrHead;
        var ss = LocalDAO.getShareGameInvite();
        ss.overview.gameKind="0";
        ss.overview.createrCompany = "";
        ss.overview.createrNickname = createrNickName;  //创建人昵称
        ss.overview.gameAmount =gameAmount ;   //君元宝
        ss.overview.beginDate = beginDate;
        ss.overview.endDate = endDate;
        ss.overview.gameNeedAmount =gameNeedAmount ;
        ss.overview.gameId = gameId;
        ss.overview.createrHead =createrHead ;
        ss.overview.gameName =gameName ;
        ss.password.gamePWD = gamePWD;
        ss.adDownload.userCode = self.userCode ;

        LocalDAO.setShareGameInvite(ss);

			},
			share2QQ(){
				var self = this;
				RemoteDAO.sendShareData(Constant.storage.SHARE_GAME_INVITE,function(data){
          var url = "https://dl.app.gtja.com/nrng/share/share.game-invite.html?userCode=" + self.userCode  + "&url=" + data;
          window.location.href ="gtjayyznormal://yyzShare?title=沉迷比赛无法自拔&content=来啊~互相伤害&activitycode=201611_NRNG&shareplace=qq&icon=https://dl.app.gtja.com/nrng/shareimages/bisaibaoming.png&linkurl="+url;
        });
        // 点击埋点
        	TDAPP.onEvent("1013","",{"usercode":self.userCode,"k2":"QQ"});
        	TDAPP.send();
			},
			share2WB(){
				RemoteDAO.sendShareData(Constant.storage.SHARE_GAME_INVITE,function(data){
                var url = "https://dl.app.gtja.com/nrng/share/share.game-invite.html?userCode=" + self.userCode  + "&url=" + data;
                window.location.href ="gtjayyznormal://yyzShare?title=沉迷比赛无法自拔&content=来啊~互相伤害&activitycode=201611_NRNG&shareplace=weixinfriend&icon=https://dl.app.gtja.com/nrng/shareimages/bisaibaoming.png&linkurl="+url;

            });
            //点击埋点
        	TDAPP.onEvent("1013","",{"usercode":self.userCode,"k2":"weibo"});
        	TDAPP.send();

			},
			share2WeChat(){
				RemoteDAO.sendShareData(Constant.storage.SHARE_GAME_INVITE,function(data){
          var url = "https://dl.app.gtja.com/nrng/share/share.game-invite.html?userCode=" + self.userCode  + "&url=" + data;
          window.location.href ="gtjayyznormal://yyzShare?title=沉迷比赛无法自拔&content=来啊~互相伤害&activitycode=201611_NRNG&shareplace=weibo&icon=https://dl.app.gtja.com/nrng/shareimages/bisaibaoming.png&linkurl="+url;

        });
        //点击埋点
        	TDAPP.onEvent("1013","",{"usercode":self.userCode,"k2":"weixin"});
        	TDAPP.send();

      },
      share2WCTimeline(){//to 朋友圈
      	RemoteDAO.sendShareData(Constant.storage.SHARE_GAME_INVITE,function(data){
                var url = "https://dl.app.gtja.com/nrng/share/share.game-invite.html?userCode=" + self.userCode  + "&url=" + data;
                window.location.href ="gtjayyznormal://yyzShare?title=沉迷比赛无法自拔&content=来啊~互相伤害&activitycode=201611_NRNG&moments=title&shareplace=moments&icon=https://dl.app.gtja.com/nrng/shareimages/bisaibaoming.png&linkurl="+url;

            });
            //点击埋点
            	TDAPP.onEvent("1013","",{"usercode":self.userCode,"k2":"friend"});
            	TDAPP.send();

      }
		}
	}
</script>

<style type="text/css" scoped>
	.game-succ-content{
    height: 100%;
    background-color: #F2F3F6;
	}
	.game-succ-content .upper img{
	  width: 100%;
	}
	#game-succ-down{
	  background-color: #F2F3F6;
	}
	.game-succ-content .upper_title{
		padding-top: 15%;
	    color:#FF5500 ;
	    font-size: 1.9em;
	    font-weight: bold;
	}
	.game-succ-content .upper_substr{
	    padding-top: 2%;
	    color:#525252 ;
	    font-size: 1.3em;
	}
	.game-succ-content .down{
	    text-align: center;
	    margin-bottom: 5px;
	    width: 100%;
	}
	.game-succ-content .down td{
	    padding-bottom: 10px;
	}
	.game-succ-content .down img{
	    width: 30%;
	    margin-bottom: -5%;
	    margin-top: 10px;
	}
	.game-succ-content .down-tr1{
	    border-bottom: dotted 1px #E0E0E0;
	}
	.game-succ-content .down-tr1-td1{
	    border-right: dotted 1px #E0E0E0;
	}
	.game-succ-content .down-tr2-td1{
	    border-right: dotted 1px #E0E0E0;
	}
</style>
